package com.sky.mapper;

import com.sky.dto.GoodsSalesDTO;
import com.sky.entity.OrderDetail;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderDetailMapper {

    void batchInsert(List<OrderDetail> orderDetailList);


    @Select("SELECT od.name as name,SUM(od.number) as number FROM orders o,order_detail od WHERE o.id = od.order_id AND o.order_time> #{beginTime} and o.order_time < #{endTime}  GROUP BY name ORDER BY  number DESC  LIMIT 10 ")
    List<GoodsSalesDTO> getSaleTop(LocalDateTime beginTime, LocalDateTime endTime);

    @Select("select * from  order_detail where order_id = #{orderId}")
    List<OrderDetail> queryByOrderId(Long orderId);
}
